<p><b>This page contains popup menu used for automatically selecting a page or URL</b></p>
<p>Here is another example on how JavaScript can be used in a form with a popup menu that has links to other pages. This example does not require a special "Go" button, the actions takes place after a selection is made in the pop up menu.</p>
<form>
Select a Page: <select name="menu" onChange="top.location.href = this.form.menu.options[this.form.menu.selectedIndex].value">
<option selected value="index.html">Contents
<option value="groucho.html">Groucho
<option value="harpo.html">Harpo
<option value="chico.html">Chico
<option value="zeppo.html">Zeppo
</select>
</form>
<hr>
<b>How to use</b>
<blockquote>
<p>The source of the popup menu looks like this:</p>
Change the links and text to be displayed in the menu by editing the lines containing the <code>OPTION</code> tags. Note that you can also use full URL's in the VALUE attribute.
</blockquote>
<hr>
<p>
<b>Programming notes</b>
<blockquote>
<p>The actual JavaScript is in the selection list's onChange handler. The JavaScript array <code>this.form.menu.options</code> is an array of the option tags (with its contents) in the form named "menu". To find which menu item that is selected we can use the property <code>this.form.menu.selectedIndex</code>, that holds the index of the selected item.</p>
<p>
We then get the name of the page by accessing the value attribute of the selected item in the array with the expression <code>this.form.menu.options[this.form.menu.selectedIndex].value</code>.</p>
<p>
<code>top.location.href</code> is the address of the url to be displayed in the window. Since we set <code>top.location</code> to contain the new pages URL, the new page will be displayed in the entire window, even if our page is inside a frame.</p>
<p>
If you want to change the contents inside a specific frame, you can try to replace <code>top</code> with the <tt>top.frames.<i>name_of_the_frame</i></tt>. For example, if the frame is named "contact" in the frame definition page, the frame's source can be accessed like this: <code>top.frames.contact.location.href</code>.</p>